﻿@using SCMS.Resources
@model SCMS.UI.Models.PPItemModel

@{
    string onsuccess = ViewBag.Action == "Update" ? "CloseDialog" : "ClearForm";
    AjaxOptions ajaxOpts = new AjaxOptions
    {
        UpdateTargetId = "ppDiv",
        LoadingElementId = "loading",
        HttpMethod = "Post",
        Url = Url.Action("SaveProcPlanItem"),
        OnSuccess = onsuccess
    };
}

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Ajax.BeginForm(null, null, ajaxOpts, new { @class = "form" }))
{
    @Html.ValidationSummary(true)
        <table>
            <tr>
                <td align="right" valign="top" class="editor-label">
                    @Resources_morgan.Global_String_ItemName:
                </td>
                <td align="left" class="editor-field">
                    @Html.DropDownListFor(model => model.EntityPPItem.ItemId, Model.Items, Resources_frank.Global_String_PleaseSelect)
                    @Html.ValidationMessageFor(model => model.EntityPPItem.ItemId, Resources_frank.Global_String_Required)
                    @Html.HiddenFor(model => model.EntityPPItem.Id)
                    @Html.HiddenFor(model => model.EntityPPItem.ProcurementPlanId)
                </td>
            </tr>
            <tr>
                <td align="right" valign="top" class="editor-label">
                    @Resources_frank.Global_String_Description:
                </td>
                <td align="left" class="editor-field">
                    @Html.TextAreaFor(model => model.EntityPPItem.ItemDescription)
                    @Html.ValidationMessageFor(model => model.EntityPPItem.ItemDescription)
                </td>
            </tr>
            <tr>
                <td align="right" valign="top" class="editor-label">
                    @Resources_morgan.Global_String_Quantity:
                </td>
                <td align="left" class="editor-field">
                    @Html.TextBoxFor(model => model.EntityPPItem.Quantity, new { id = "Quatity", onblur = "javascript:ComputeTotals()", @autocomplete = "off", @class = "numericTb" })
                    @Html.ValidationMessageFor(model => model.EntityPPItem.Quantity, Resources_frank.Global_String_Required)
                </td>
            </tr>
            <tr>
                <td align="right" valign="top" class="editor-label">
                    @Resources_frank.Global_String_Currency:
                </td>
                <td align="left" class="editor-field">
                    @Html.DropDownListFor(model => model.EntityPPItem.CurrencyId, Model.Currencies, Resources_frank.Global_String_PleaseSelect)
                    @Html.ValidationMessageFor(model => model.EntityPPItem.ItemId, Resources_frank.Global_String_Required)
                </td>
            </tr>
            <tr>
                <td align="right" valign="top" class="editor-label">
                    @Resources_frank.OrderRequest_AddItemInEditMode_EstUnitPrice:
                </td>
                <td align="left" class="editor-field">
                    @Html.TextBoxFor(model => model.EntityPPItem.UnitCost, new { id = "UnityPrice", onblur = "javascript:ComputeTotals()", @autocomplete = "off", @class = "numericTb" })
                    @Html.ValidationMessageFor(model => model.EntityPPItem.UnitCost, Resources_frank.Global_String_Required)
                </td>
            </tr>
            <tr>
                <td align="right" valign="top" class="editor-label">
                    @Resources_frank.OrderRequest_AddItemInEditMode_EstTotalPrice:
                </td>
                <td align="left" class="editor-field">
                    @Html.TextBoxFor(model => model.EntityPPItem.TotalCost, new { id = "TotalPrice", @readonly = "readonly", @class = "numericTb" })
                    @Html.ValidationMessageFor(model => model.EntityPPItem.TotalCost, Resources_frank.Global_String_Required)
                </td>
            </tr>
            <tr>
                <td align="right" valign="top" class="editor-label">
                    @Resources_frank.Budget_CreateSubLine_LineNumber:
                </td>
                <td align="left" class="editor-field">
                    <div id="PBlines">
                        @Html.DropDownListFor(model => model.EntityPPItem.BudgetLineId, Model.BudgetLines, Resources_frank.Global_String_PleaseSelect, new { @class = "dpl", @id = "BudgetLineID" })
                        @Html.ValidationMessageFor(model => model.EntityPPItem.BudgetLineId, Resources_frank.Global_String_Required)
                    </div>
                </td>
            </tr>
            <tr>
                <td align="right" valign="top" class="editor-label">
                    @Resources_frank.Global_String_DeliveryLocation:
                </td>
                <td align="left" class="editor-field">
                    @Html.DropDownListFor(model => model.EntityPPItem.DeliveryLocationId, Model.Locations, Resources_frank.Global_String_PleaseSelect)
                    @Html.ValidationMessageFor(model => model.EntityPPItem.DeliveryLocationId, Resources_frank.Global_String_Required)
                </td>
            </tr>
            <tr>
                <td align="right" valign="top" class="editor-label">
                    @Resources_frank.GoodsReceivedNote_LoadGRNVerifyItems_DeliveryDate:
                </td>
                <td align="left" class="editor-field">
                    @Html.EditorFor(model => model.EntityPPItem.RequiredDeliveryDate)
                </td>
            </tr>
            <tr>
                <td align="left" class="editor-label">
                </td>
                <td align="left" class="editor-field">
                    <input type="submit" class="btn green"  value="@ViewBag.Action" />
                </td>
            </tr>
        </table>
}